<template>
  <div id="luckysheet5">

  </div>
</template>

<script>
import LuckyExcel from 'luckyexcel';
import {Message} from "element-ui";
import moment from "moment";

export default {
  name: "daySheet3",
  created() {
    this.axios.post('/jmreport/exportAllExcelStream', {
      "excelConfigId": "973351806924541952",
      "queryParam": {
        "pageNo": "1",
        "pageSize": 10,
        "currentPageNo": "1",
        "currentPageSize": 10,
        "date": moment().format('yyyy-MM-DD')
      }
    }, {responseType: 'arraybuffer'}).then(res => {

      let blob = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});

      let file = new File([blob], "example.xlsx", {
        type: blob.type,
      });

      this.file = file;

      LuckyExcel.transformExcelToLucky(file, function (exportJson, luckysheetfile) {
          if (exportJson.sheets == null || exportJson.sheets.length === 0) {
            Message.warning("读取excel文件内容失败");
            return;
          }
          exportJson.sheets[0]["zoomRatio"] = 0.8;
          const options = {
            container: 'luckysheet5',
            showinfobar: false,
            data: exportJson.sheets,
            showsheetbar: false,
            sheetFormulaBar: false,
          };
          luckysheet.create(options);
        }, function (err) {
          Message.warning('Import failed. Is your fail a valid xlsx?');
        }
      );

    })
  },
  methods: {
    init() {
    },

  },
  data() {
    return {
      xs: null,
      fileList: [],
      file: null,
      autoGenerateColumns: false,
      spread: null,
      selectedFile: null,
    };
  },
  mounted() {
  },
}
</script>

<style scoped>
#luckysheet5 {
  margin: 0px;
  padding: 0px;
  position: relative;
  width: 100%;
  height: 100%;
  left: 0px;
  top: 0px;
}
</style>
